<?php
// Copyright (C) 2012 Rod Roark <rod@sunsetsystems.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.


	//SANITIZE ALL ESCAPES
	$sanitize_all_escapes=true;

	//STOP FAKE REGISTER GLOBALS
	$fake_register_globals=false;

        //continue session
        if (!isset($_REQUEST['medico'])) 
    session_start();
        //
		//landing page definition -- where to go if something goes wrong
	$landingpage = "index.php?site=".$_SESSION['site_id'];
	//

        // kick out if patient not authenticated
        if ( isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite']) ) {
                $pid = $_SESSION['pid'];
        }
        else {
                session_destroy();
                header('Location: '.$landingpage.'&w');
                exit;
        }
        //

	$ignoreAuth=true;
	
	//echo $_SESSION['pid'];die;
	//echo "globals---".$GLOBALS["srcdir"];
	
	//echo "<pre>";
	//print_r($GLOBALS);
	//echo "</pre>";
	
	
require_once($_SESSION['WEB_ROOT'].'/interface/globals.php');

	//echo "<pre>";
	//print_r($_SESSION);
	//echo "</pre>";

require_once($GLOBALS["srcdir"] . "/formdata.inc.php");

//echo $_SESSION['WEB_ROOT'];

$ptid     = $_GET['ptid'] + 0;
$encid    = $_GET['encid'] + 0;
$formname = strtr($_GET['formname'],
  array('.' => '', '\\' => '', '/' => '', '\'' => '', '"' => '', "\r" => '', "\n" => ''));
$formid   = $_GET['formid'] + 0;

if (substr($formname, 0, 3) == 'LBF') {
  include_once("{$GLOBALS['incdir']}/forms/LBF/report.php");
  lbf_report($ptid, $encid, 2, $formid, $formname);
}
else {
  include_once("{$GLOBALS['incdir']}/forms/$formname/report.php");
  $report_function = $formname . '_report';
  if (!function_exists($report_function)) exit;
  call_user_func($report_function, $ptid, $encid, 2, $formid);
}
?>